<h3>找回密码</h3>
<div id="one">
<h4>输入验证码</h4>
手机号：<input type="text" name="mobile" id="mobile" >&nbsp;<span>输入注册时所填写的手机号</span><br><br>
验证码：<input type="text" name="captcha" id="captcha" >&nbsp;
		<span>
			<a autocomplete="off" target="_self" id="user_getcode" href="javascript:void(0);" class="logCenter">获取验证码</a>
		</span><br>
		<a id="submitbtn1" href="javascript:;" class="loginm loginm-1">下一步</a>
</div>
<div id="two">
<h4>设置新密码</h4>
新密码：<input type="password" name="password" id="password" >&nbsp;<span></span><br><br>
再次输入：<input type="password" name="password2" id="password2" >&nbsp;
	
	   <br><a id="submitbtn2" href="javascript:;" class="loginm loginm-1">下一步</a>

</div>

<div id="three">
<h4>完成</h4>
	<div id="msg"></div>
	<a href="/communal/login" class="loginm loginm-1">重新登录</a>
</div>


<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
	$('#user_getcode').hide();
	$('#two').hide();
	$('#three').hide();
});
$('#mobile').change(function(){
	var mobile = $('#mobile').val();
	if(!cp_check_moblie(mobile)){
		alert('手机号码格式不正确!');
		return false;
	}
	$.ajax({
        type : 'POST',
        url  : '<?php echo base_url('communal/getmobile');?>',
        data : {'mobile':mobile},
        success:function(msg){
            var json = eval('('+msg+')');
            if(json.err > 0){
                alert(json.msg);
                $('#user_getcode').hide();
                return false;
            }
            if(json.err == 0){
            	$('#user_getcode').show();
            }
            
        }
    });
});
$('#user_getcode').click(function(){ // 发送短信验证码
	var mobile = $('#mobile').val();
	$.ajax({
        type : 'POST',
        url  : '<?php echo base_url('communal/captcha');?>',
        data : {'mobile':mobile},
        success:function(msg){
            var json = eval('('+msg+')');
            if(json.err > 0){
                alert(json.msg);
                return false;
            }
            if(json.err == 0){
            	$('#user_getcode').hide();
            }
            
        }
    });
});
$('#submitbtn1').click(function(){ // 第一个下一步
	var captcha = $('#captcha').val();
	$.ajax({
        type : 'POST',
        url  : '<?php echo base_url('communal/yzcaptcha');?>',
        data : {'captcha':captcha},
        success:function(msg){
            var json = eval('('+msg+')');
            if(json.err > 0){
                alert(json.msg);
                return false;
            }
            if(json.err == 0){
            	$('#two').show();
            	$('#one').hide();
            	$('#three').hide();
            }
            
        }
    });
});

$('#submitbtn2').click(function(){ // 第二个下一步
	var password = $('#password').val();
	$.ajax({
        type : 'POST',
        url  : '<?php echo base_url('communal/member_update');?>',
        data : {'password':password},
        success:function(msg){
            var json = eval('('+msg+')');
            if(json.err > 0){
                alert(json.msg);
                return false;
            }
            if(json.err == 0){
            	$('#msg').html('恭喜，新密码已修改成功！');
            	$('#one').hide();
            	$('#two').hide();
            	$('#three').show();
            }
            
        }
    });
});


//简单手机验证
function cp_check_moblie(mobile){
    var reg = new RegExp('^1[0-9]{10,10}$');
    if(reg.test(mobile)){
        return true;
    }else{
        return false;
    }
    return false;
}

</script>